﻿namespace WebSocketApi.CacheManager;

/// <summary>
/// 缓存接口
/// </summary>
public interface ICacheContext
{
    /// <summary>
    /// Exists
    /// </summary>
    /// <param name="key"></param>
    /// <returns></returns>
    bool Exists(string key);
    /// <summary>
    /// 读取缓存
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="key"></param>
    /// <returns></returns>
    T GetCache<T>(string key);
    /// <summary>
    /// 设置缓存
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="key"></param>
    /// <param name="value"></param>
    /// <returns></returns>
    bool SetCache<T>(string key, T value);
    /// <summary>
    /// 设置缓存
    /// </summary>
    /// <param name="key"></param>
    /// <param name="value"></param>
    /// <param name="expire"></param>
    bool SetCache<T>(string key, T value, DateTime expire);
    /// <summary>
    /// 删除缓存
    /// </summary>
    /// <param name="key"></param>
    /// <returns></returns>
    bool Remove(string key);
    /// <summary>
    /// 重命名Key
    /// </summary>
    /// <param name="key"></param>
    /// <param name="newKey"></param>
    /// <returns></returns>
    bool RenameKey(string key, string newKey);
}
